package day04.interFace2;

/**
 * @author yangwenqi
 * @decs TODO
 * @date 2025/4/22
 */
public class Computer {

    public void dataExchange(Device device) {
        String readdata = device.readData();
        System.out.println(readdata);
        device.writeData("新数据");
    }

    public static void main(String[] args) {
        Computer computer = new Computer();
        // 与U盘进行数据交换
        Device usb = new USB();
        computer.dataExchange(usb);
        System.out.println("-------------------");

        // 与移动硬盘进行数据交换
        Device hardDisk = new HardDisk();
        computer.dataExchange(hardDisk);
        System.out.println("-------------------");

        // 与MP3播放器进行数据交换
        MP3Player mp3 = new MP3Player();
        computer.dataExchange(mp3);
        mp3.playMusic();
    }
}
